#include"tcpServer.hpp"
#include<memory>
#include"daemon.hpp"

using namespace server;
using namespace std;

static void Usage(string proc)
{
    cout << "\nUsage:\n\t" << proc << "  local port\n\n";
}


// tcp服务器，启动上跟udp server一模一样
// ./tcpServer local_port
int main(int argc,char* argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }

    uint16_t port = atoi(argv[1]);
    // string ip = argv[1];
    std::unique_ptr<TcpServer>tser (new TcpServer(port));

    tser->initServer();
    daemonSelf();
    tser->start();
    return 0;
}